#include "InteractiveIterativeClosestPointModel.h"

#include "core/AppDirectory.h"

namespace {
const QString UserFilename = "pcl.interactive_iterative_closest_point_model.json";
}

InteractiveIterativeClosestPointModel::InteractiveIterativeClosestPointModel()
    : BasePclModel()
{
    setPclHelpPage("https://pcl.readthedocs.io/projects/tutorials/en/master/interactive_icp.html");
}

InteractiveIterativeClosestPointModel& InteractiveIterativeClosestPointModel::get()
{
    static InteractiveIterativeClosestPointModel instance;
    if (instance.filename().isEmpty()) {
        instance.setFilename(AppDirectory::get().getAppDocFile(UserFilename));
        instance.load();
    }
    return instance;
}

void InteractiveIterativeClosestPointModel::fromJson(const QJsonObject& json, QStringList& errorList)
{
    BasePclModel::fromJson(json, errorList);

    pcdFile_ = json["pcdFile"].toString(pcdFile_);
}

QJsonObject InteractiveIterativeClosestPointModel::toJson() const
{
    QJsonObject json = BasePclModel::toJson();

    json.insert("pcdFile", QJsonValue(pcdFile_));

    return json;
}
